
module iopmp_top(
input            iopmp_m2s_ahb_hclk         ,
input            iopmp_m2s_ahb_hrst_b       ,
input [31:0]     iopmp_m2s_ahb_haddr_i      ,
input [2 :0]     iopmp_m2s_ahb_hburst_i     ,
input [3 :0]     iopmp_m2s_ahb_hprot_i      ,
input            iopmp_m2s_ahb_hsel_i       ,
input [2 :0]     iopmp_m2s_ahb_hsize_i      ,
input [1 :0]     iopmp_m2s_ahb_htrans_i     ,
input [31:0]     iopmp_m2s_ahb_hwdata_i     ,
input            iopmp_m2s_ahb_hwrite_i     ,
        
input [31:0]     iopmp_s2m_ahb_hrdata_i     ,
input            iopmp_s2m_ahb_hready_i     ,
input [1 :0]     iopmp_s2m_ahb_hresp_i      ,
     
input            iopmp_reg_s3clk_i          ,
input            iopmp_reg_s3rst_b_i        ,
input  [31 : 0]  iopmp_reg_haddr_i          ,
input  [3 : 0]   iopmp_reg_hprot_i          ,
input            iopmp_reg_hsel_i           ,
input  [2 : 0]   iopmp_reg_hsize_i          ,
input  [1 : 0]   iopmp_reg_htrans_i         ,
input  [31 : 0]  iopmp_reg_hwdata_i         ,
input            iopmp_reg_hwrite_i         ,
    
output [31 : 0]  iopmp_reg_hrdata_o         ,
output           iopmp_reg_hready_o         ,
output [1 : 0]   iopmp_reg_hresp_o          ,
output [1 : 0]   iopmp_reg_intr_o           ,

output [31 : 0] iopmp_m2s_ahb_check_haddr_o ,
output [2 : 0]  iopmp_m2s_ahb_check_hburst_o,
output [3 : 0]  iopmp_m2s_ahb_check_hprot_o ,
output          iopmp_m2s_ahb_check_hsel_o  ,
output [2 : 0]  iopmp_m2s_ahb_check_hsize_o ,
output [1 : 0]  iopmp_m2s_ahb_check_htrans_o,
output [31 : 0] iopmp_m2s_ahb_check_hwdata_o,
output          iopmp_m2s_ahb_check_hwrite_o,

output [31 : 0] iopmp_s2m_ahb_check_hrdata_o,
output          iopmp_s2m_ahb_check_hready_o,
output [1 : 0]  iopmp_s2m_ahb_check_hresp_o ,
output          iopmp_s2m_ahb_check_intr_o  
);


wire [31 : 0]                cfg2ck_rule      ;
wire                         ctl2ck_checken   ;
wire                         ck2cfg_error_flag;
wire [15:0]                  ck2cfg_error_hit ;  
wire                         ck2ctl_hwren     ;
wire                         ck2ctl_hrden     ;
wire                         ck2ctl_hrdy      ;                  
wire                         cfg2ctl_cfgen    ;
wire                         ctl2cfg_cfgdone  ;
wire[3:0]                    ctl2ck_state_n   ;

iopmp_check u_iopmp_check(
    .iopmpck_clk_i            (iopmp_m2s_ahb_hclk       ),
    .iopmpck_rst_n_i          (iopmp_m2s_ahb_hrst_b     ),
    // from sr_reg
    .iopmpck_rule_i           (cfg2ck_rule              ),
    // from io_control
    .iopmpck_check_en_i       (ctl2ck_checken           ),
    .iopmpck_state_n_i        (ctl2ck_state_n           ),
    

    //from master
    .iopmpck_haddr_i          (iopmp_m2s_ahb_haddr_i        ),
    .iopmpck_hburst_i         (iopmp_m2s_ahb_hburst_i       ),
    .iopmpck_hprot_i          (iopmp_m2s_ahb_hprot_i        ),       //hprot[0]娑擄拷0閿涘奔鍞悰銊︽Ц閺夈儴鍤渢ee閻ㄥ嫯顔栭梻顔讳繆閸欏嚖绱濇稉锟�1閿涘奔鍞悰銊︽Ц閺夈儴鍤渞ee閻ㄥ嫯顔栭梻顔讳繆閸欙拷
    .iopmpck_hsel_i           (iopmp_m2s_ahb_hsel_i         ),
    .iopmpck_hsize_i          (iopmp_m2s_ahb_hsize_i        ),
    .iopmpck_htrans_i         (iopmp_m2s_ahb_htrans_i       ),
    .iopmpck_hwdata_i         (iopmp_m2s_ahb_hwdata_i       ),
    .iopmpck_hwrite_i         (iopmp_m2s_ahb_hwrite_i       ),
    //from slave
    .iopmpck_hrdata_i         (iopmp_s2m_ahb_hrdata_i       ),
    .iopmpck_hready_i         (iopmp_s2m_ahb_hready_i       ),
    .iopmpck_hresp_i          (iopmp_s2m_ahb_hresp_i        ),
    .iopmpck_intr_i           (1'b0                         ),

   //to slave
    .iopmpck_haddr_o          (iopmp_m2s_ahb_check_haddr_o ),
    .iopmpck_hburst_o         (iopmp_m2s_ahb_check_hburst_o),
    .iopmpck_hprot_o          (iopmp_m2s_ahb_check_hprot_o ), 
    .iopmpck_hsel_o           (iopmp_m2s_ahb_check_hsel_o  ),
    .iopmpck_hsize_o          (iopmp_m2s_ahb_check_hsize_o ),
    .iopmpck_htrans_o         (iopmp_m2s_ahb_check_htrans_o),
    .iopmpck_hwdata_o         (iopmp_m2s_ahb_check_hwdata_o),
    .iopmpck_hwrite_o         (iopmp_m2s_ahb_check_hwrite_o),
    //to master
    .iopmpck_hrdata_o         (iopmp_s2m_ahb_check_hrdata_o),
    .iopmpck_hready_o         (iopmp_s2m_ahb_check_hready_o),
    .iopmpck_hresp_o          (iopmp_s2m_ahb_check_hresp_o ),
    .iopmpck_intr_o           (iopmp_s2m_ahb_check_intr_o  ),
    //to sr_reg
    .iopmpck_error_o          (ck2cfg_error_flag         ),
    .iopmpck_iohit_o          (ck2cfg_error_hit           ),
    //to sr_control
    .iopmpck_hwren_o          (ck2ctl_hwren              ),
    .iopmpck_hrden_o          (ck2ctl_hrden              ),
    .iopmpck_hrdy_o           (ck2ctl_hrdy               )
);


iopmp_control u_iopmp_control(
    .iopmpctl_clk_i           (iopmp_m2s_ahb_hclk        ),
    .iopmpctl_rst_n_i         (iopmp_m2s_ahb_hrst_b      ),
        
    .iopmpctl_cfgen_i         (cfg2ctl_cfgen             ),        

    .iopmpctl_hwren_i         (ck2ctl_hwren              ),
    .iopmpctl_hrden_i         (ck2ctl_hrden              ),
    .iopmpctl_hready_i        (ck2ctl_hrdy               ),
     
    .iopmpctl_check_en_o      (ctl2ck_checken            ), 
    .iopmpctl_state_n_o       (ctl2ck_state_n            ),
    .iopmpctl_cfgdone_o       (ctl2cfg_cfgdone           )
);














iopmp_config u_iopmp_config(
    .iopmpcfg_clk_i       (iopmp_reg_s3clk_i     ),
    .iopmpcfg_rst_n_i     (iopmp_reg_s3rst_b_i   ),
    .iopmpcfg_haddr_i     (iopmp_reg_haddr_i     ),
    .iopmpcfg_hprot_i     (iopmp_reg_hprot_i     ),                         
    .iopmpcfg_hsel_i      (iopmp_reg_hsel_i      ),
    .iopmpcfg_hsize_i     (iopmp_reg_hsize_i     ),
    .iopmpcfg_htrans_i    (iopmp_reg_htrans_i    ),
    .iopmpcfg_hwdata_i    (iopmp_reg_hwdata_i    ),
    .iopmpcfg_hwrite_i    (iopmp_reg_hwrite_i    ),

    .iopmpcfg_access_ill_i(ck2cfg_error_flag     ),
    .iopmpcfg_hit_i       (ck2cfg_error_hit      ),

    .iopmpcfg_cfgdone_i   (ctl2cfg_cfgdone       ),

    .iopmpcfg_cfgen_o     (cfg2ctl_cfgen         ),

    .iopmpcfg_rule_o      (cfg2ck_rule           ),

    .iopmpcfg_hrdata_o    (iopmp_reg_hrdata_o    ),
    .iopmpcfg_hready_o    (iopmp_reg_hready_o    ),
    .iopmpcfg_hresp_o     (iopmp_reg_hresp_o     ),
    .iopmpcfg_r2t_intr_o  (iopmp_reg_intr_o      )
);
endmodule